<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>抓取新闻-后台管理-<?php echo ($site["SITE_INFO"]["name"]); ?></title>
        <?php $addCss=""; $addJs=""; $currentNav ='资讯管理 > 抓取新闻'; ?>
        <base href="<?php echo ($site["WEB_ROOT"]); ?>"/>
<link rel="shortcut icon" href="<?php echo ($site["WEB_ROOT"]); ?>favicon.ico" />
<link rel="stylesheet" type="text/css" href="<?php echo ($site["WEB_ROOT"]); ?>Public/Min/?f=../Public/Css/base.css|../Public/Css/layout.css|__PUBLIC__/Js/asyncbox/skins/default.css<?php echo ($addCss); ?>|../Public/Css/uploadify.css" />
<script type="text/javascript" src="<?php echo ($site["WEB_ROOT"]); ?>Public/Min/?f=__PUBLIC__/Js/jquery-1.9.0.min.js|__PUBLIC__/Js/jquery.lazyload.js|__PUBLIC__/Js/functions.js|../Public/Js/base.js|__PUBLIC__/Js/jquery.form.js|__PUBLIC__/Js/asyncbox/asyncbox.js<?php echo ($addJs); ?>|../Public/Js/jquery.uploadify.min.js"></script>
    </head>
    <body>
        <div class="wrap">
            <div id="Top">
    <div class="logo"><a href="<?php echo ($site["WEB_ROOT"]); ?>"><img src="../Public/Img/logo.png" /></a></div>
    <div class="help"><a href="#">使用帮助</a><span><a href="#">关于</a></span></div>
    <div class="menu">
        <ul> <?php echo ($menu); ?> </ul>
    </div>
</div>
<div id="Tags">
    <div class="userPhoto"><img src="../Public/Img/userPhoto.jpg" /> </div>
    <div class="navArea">
        <div class="userInfo"><div><a href="/" class="wwwInfo"><span>&nbsp;</span>系统设置</a> <a href="<?php echo U('Webinfo/index');?>" class="sysSet"><span>&nbsp;</span>系统设置</a> <a href="<?php echo U("Public/loginOut");?>" class="loginOut"><span>&nbsp;</span>退出系统</a></div>欢迎您，<?php echo ($my_info["email"]); ?> | <a href="#">个人信息管理</a> | <a href="#">个人信息管理</a> | <a href="#">个人信息管理</a></div>
        <div class="nav"><font id="today"><?php echo date("Y-m-d H:i:s"); ?></font>您的位置：<?php echo ($currentNav); ?></div>
    </div>
</div>
<div class="clear"></div>
            <div class="mainBody">
                <div id="Left">
    <div id="control" class=""></div>
    <div class="subMenuList">
        <div class="itemTitle"><?php if(MODULE_NAME == 'Index'): ?>常用操作<?php else: ?>子菜单<?php endif; ?> </div>
        <ul>
            <?php if(is_array($sub_menu)): foreach($sub_menu as $key=>$sv): ?><li><a href="<?php echo ($sv["url"]); ?>"><?php echo ($sv["title"]); ?></a></li><?php endforeach; endif; ?>
        </ul>
    </div>
    <div class="QRcode">移动设备访问本页：<br/><br/><img src="<?php echo ($QRcodeUrl); ?>"/></div>
</div>
                <div id="Right">
                    <div class="Item hr">
                        <div class="current">抓取新闻</div>
                    </div>
                    <form>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
                            <tr>
                                <th width="100">抓取地址：</th>
                                <td><input id="url" type="text" class="input" size="60" name="url" /> <a href="javascript:void(0)" <?php if($type != 'Batch'): ?>id="urlGetInfo"<?php else: ?>id="urlListInfo"<?php endif; ?>>地址信息抓取</a><img src=""> </td>
                            </tr>
                            <?php if($type != 'Batch'): ?><tr>
                                <th width="100">文章标题：</th>
                                <td><input id="title" type="text" class="input" size="60" name="info[title]" value="<?php echo ($info["title"]); ?>"/> <a href="javascript:void(0)" id="checkNewsTitle">检测是否重复</a></td>
                            </tr>
                            <tr>
                                <th width="100">文章图片：</th>
                                <td>
                                    <select name="info[picture]" id="picture">
                                        <option value="1">请先抓取信息</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th width="100">文章标签：</th>
                                <td><input id="tag" type="text" class="input" size="60" name="info[tag]" value="<?php echo ($info["tag"]); ?>"/>  多标签间用半角逗号（,）分开，可用于做文章关联阅读条件</td>
                            </tr>
                            <tr>
                                <th width="100">文章发布状态：</th>
                                <td><label><input type="radio" name="info[status]" value="0" <?php if($info["status"] == 0): ?>checked="checked"<?php endif; ?> /> 文章审核状态</label> &nbsp; <label><input type="radio" name="info[status]" value="1" <?php if($info["status"] == 1): ?>checked="checked"<?php endif; ?> /> 文章已发布状态</label> </td>
                            </tr>
                            <tr>
                                <th>文章所属分类：</th>
                                <td>
                                    <select name="info[cid]">
                                        <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if($vo[cid] == $info[cid]): ?><option value="<?php echo ($vo["cid"]); ?>" selected="selected"><?php echo ($vo["fullname"]); ?></option>
                                                <?php else: ?>
                                                <option value="<?php echo ($vo["cid"]); ?>"><?php echo ($vo["fullname"]); ?></option><?php endif; endforeach; endif; else: echo "" ;endif; ?>
                                    </select></td>
                            </tr>
                            <tr>
                                <th>文章关键词：</th>
                                <td><input type="text" id="keywords" class="input" size="60" name="info[keywords]" value="<?php echo ($info["keywords"]); ?>"/> 多关键词间用半角逗号（,）分开，可用于做文章关联阅读条件</td>
                            </tr>
                            <tr>
                                <th>文章描述：</th>
                                <td><textarea class="input" id="description" style="height: 60px; width: 600px;" name="info[description]"><?php echo ($info["description"]); ?></textarea> 用于SEO的description</td>
                            </tr>
                            <tr>
                                <th>文章摘要：</th>
                                <td><textarea class="input" id="summary" style="height: 60px; width: 600px;" name="info[summary]"><?php echo ($info["summary"]); ?></textarea> 如果不填写则系统自动截取文章前200个字符</td>
                            </tr>
                            <tr>
                                <th>文章内容：</th>
                                <td><textarea id="content"  class="input" style="height: 300px; width: 100%;" name="info[content]"><?php echo ($info["content"]); ?></textarea></td>
                            </tr><?php endif; ?>
                        </table>
                        <input type="hidden" name="info[id]" value="<?php echo ($info["id"]); ?>" />
                        <input type="hidden" name="info[spiderType]" value="" />
                    </form>
                    <div class="commonBtnArea" >
                        <button class="btn submit"> <?php if($type != 'Batch'): ?>提交<?php else: ?>批量入库<?php endif; ?></button>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <div id="Bottom">© 2013 站长微博 <a href="http://weibo.com/iwhoopsfeed" target="_blank">@哎哟喂_WhoopsFeed</a> &nbsp;&nbsp; <?php echo ($site["SITE_INFO"]["name"]); ?> <?php echo ($site["WEB_ROOT"]); ?> All rights reserved 联系我们 <?php echo ($site["SITE_INFO"]["icp"]); ?></div>
<script type="text/javascript">
    $(window).resize(autoSize);
    $(function(){
        autoSize();
        $(".loginOut").click(function(){
            var url=$(this).attr("href");
            popup.confirm('你确定要退出吗？','你确定要退出吗',function(action){
                if(action == 'ok'){ window.location=url; }
            });
            return false;
        });

        var time=self.setInterval(function(){$("#today").html(date("Y-m-d H:i:s"));},1000);


    });

</script>
        <script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor.js"></script><script type="text/javascript" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>
        <script type="text/javascript">
            $(function(){
                var  content ;
                KindEditor.ready(function(K) {
                    content = K.create('#content');
                });
                $("#urlGetInfo").click(function(){
                    var tmp = '';
                    var url_tmp= new Array();//临时变量，保存分割字符串
                    url_tmp=$("#url").val().split("/");//按照"/"分割
                    var p_tmp = url_tmp[url_tmp.length-1];//获取最后一部分，即文件名和参数
                    var p_id =p_tmp.split(".");//把参数和文件名分割开

                    $.getJSON("__URL__/spider<?php echo ($type); ?>/p_id/"+p_id[0], {}, function(json){
                        $("#urlGetInfo").css("color",json.status==1?"#0f0":"#f00").html('请仔细检查抓取信息结果');

                        if(json.info != null){
                            $.each(json.info, function(i,val){

                                if(i == 'content'){
                                    content.insertHtml(val);
                                }else if(i == 'picture'){
                                    var str = '';
                                    for(var j=1;j<=val;j++){
                                        str += '<option value="'+j+'">内容第一'+j+'图片</option>';
                                    }
                                    $("#"+i).html(str);
                                }else{
                                    $("#"+i).val(val);
                                }
                            });
                        }
                    });
                });

                var list_num = 0;
                $('#urlListInfo').click(function(){
                    list_num = 0;
                    var url_tmp= parseURL($("#url").val());

                    if(url_tmp){
                        pollSpider(url_tmp['file'],parseInt(url_tmp['params']['page']));
                    }
                });

                function pollSpider(type,page){
                    $.getJSON("__URL__/spider<?php echo ($type); ?>/type/"+type+"/page/"+page, {}, function(json){
                        if(json.info != null){
                            $.each(json.info, function(i,val){
                                var img_src = val['src'].split("!");
                                var str = '<tr href_url = "'+val['href']+'" img_src = "'+img_src[0]+'" title="'+val['title']+'" type="'+val['type']+'" time ="'+val['time']+'" summary="'+val['summary']+'">'+
                                        '<th width="100"><a href="javascript:void(0);" class="_spiderNew">第'+page+'页->'+(i+1)+'：</a></th>'+
                                        '<td>'+val['title']+'<span class="_time">&nbsp;|&nbsp;'+val['time']+'</span></td>'+
                                        '</tr>';
                                $('table.table1 tbody').append(str);

                                str = '';
                                list_num++;
                            });

                            if(parseInt(page - 1) > 0){
                                pollSpider(type,(parseInt(page) - 1));
                            }else{
                                $('#urlListInfo').parent().append('<font style="color:blue">&nbsp;&nbsp;&nbsp;&nbsp;总共：'+list_num+"条数据！</font>");
                            }
                        }
                    });
                }

                //验证新闻标题
                $("#checkNewsTitle").click(function(){
                    $.getJSON("__URL__/checkNewsTitle", { title:$("#title").val(),id:"<?php echo ($info["id"]); ?>"}, function(json){
                        $("#checkNewsTitle").css("color",json.status==1?"#0f0":"#f00").html(json.info);
                    });
                });

                $(".submit").click(function(){
                    pollAddInfo($('tr').eq(1));
                    return false;
                });

                //tr 数据抓取
                var top_num = 100;
                function pollAddInfo(dom){
                    var _self = dom;

                    if(_self.attr('href_url') == undefined){
                        return false;
                    }

                    var url_tmp= new Array();//临时变量，保存分割字符串
                    url_tmp=_self.attr('href_url').split("/");//按照"/"分割
                    var p_tmp = url_tmp[url_tmp.length-1];//获取最后一部分，即文件名和参数
                    var p_id =p_tmp.split(".");//把参数和文件名分割开

                    $.getJSON("__URL__/addNew", { id:p_id[0],src:_self.attr('img_src'),title:_self.attr('title'),summary:_self.attr('summary'),type:_self.attr('type'),time:_self.attr('time')}, function(json){
                        _self.css("color",json.status==1?"blue":"red");

                        $("#Right").animate({scrollTop:top_num},1000);

                        top_num +=_self.height();

                        if(_self.next().first()){
                            pollAddInfo(_self.next().first());
                        }
                    });
                }
            });

            function parseURL(url) {
                var a = document.createElement('a');
                a.href = url;
                return {
                    source: url,
                    protocol: a.protocol.replace(':', ''),
                    host: a.hostname,
                    port: a.port,
                    query: a.search,
                    params: (function () {
                        var ret = {},
                                seg = a.search.replace(/^\?/, '').split('&'),
                                len = seg.length, i = 0, s;
                        for (; i < len; i++) {
                            if (!seg[i]) {
                                continue;
                            }
                            s = seg[i].split('=');
                            ret[s[0]] = s[1];
                        }
                        return ret;
                    })(),
                    file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1],
                    hash: a.hash.replace('#', ''),
                    path: a.pathname.replace(/^([^\/])/, '/$1'),
                    relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1],
                    segments: a.pathname.replace(/^\//, '').split('/')
                };
            }
        </script>
    </body>
</html>